/*
 * @Autor: dingxiaolin
 * @Date: 2020-12-24 20:51:42
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2020-12-25 02:47:35
 */
import api from "@/http/api";
const userModules = {
  namespaced:true,
  state: {
    jwtToken: "aaa",
    userInfo: {
        name:''
    },
  },
  getters: {
    jwtToken:(getters)=>getters.jwtToken+'888',
    userInfo:(getters)=>getters.userInfo,
  },
  mutations: {
    updateJwt(state,jwt){
        state.jwtToken=jwt
    },
    resetUser (state) {
      state.userInfo = {}
    },
    updateUserInfo (state,userInfo) {
      state.userInfo = userInfo
    },
  },
  actions: {
    async login ({ state,dispatch, commit, getters, rootGetters }) {
        await  api.getParkInfoList();
        commit('global/setSex', "男", { root: true })//模块之间互调 第二个参数如果不传也需要预留{}或null
        // state.userInfo={name:"dingxiaolin"}
        commit('updateUserInfo',{name:"dingxiaolin"})
        wx.switchTab({
            url: '/pages/tab1/index'
        });
    }
  }
}

export default userModules
